package org.rcy.framework.thrift.metadata;

import org.apache.thrift.protocol.TType;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;

public class ListMetaData extends FieldValueMetaData {

	private static final long serialVersionUID = 1L;

	public final FieldValueMetaData elemMetaData;

	public ListMetaData(Type javaType, Type[] typeArguments){
		super(TType.LIST, javaType);
		Type[] actualTypeArguments = ((ParameterizedType) javaType).getActualTypeArguments();
		Type elemType = actualTypeArguments[0];
		
		//List泛型取自Class中定义的泛型参数
		if (elemType instanceof TypeVariable && typeArguments != null) {
			elemType = typeArguments[0];
		}
		
		this.elemMetaData = MetaDataBuilder.valueMetaData(elemType, null);
	}
}